var form;
layui.use(['form'], function () {
    form = layui.form();
    form.verify({
        verifyUserName: [/[\S]+/, "用户名不能为空"],
        verifyLoginName: [/[\S]+/, "登录名不能为空"],
        verifyPhone: function (value) {
            if (!/[\S]+/.test(value)) {
                return '手机不能为空';
            }
            if (/[\S]+/.test(value) && !/^(13|14|15|17|18)[0-9]{9}$/.test(value)) {
                return '手机格式不正确';
            }
        }
        ,
        verifyTele: function (value) {
            var teleReg = /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
            if (/[\S]+/.test(value) && !teleReg.test(value)) {
                return '电话格式不正确';
            }
        },
        verifyFax: function (value) {
            var faxReg = /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
            if (/[\S]+/.test(value) && !faxReg.test(value)) {
                return '传真格式不正确';
            }
        }
        ,
        verifyEmail: function (value) {
            var mailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if (/[\S]+/.test(value) && !mailReg.test(value)) {
                return '邮箱格式不正确';
            }
        }
        ,
        verifyPassword: [/[\S]+/, "密码不能为空"],
        verifyOldPass: [/[\S]+/, "原密码不能为空"],
        verifyNewPass: function (value) {
            if (!/[\S]+/.test(value)) {
                return '密码不能为空';
            }
            if (/[\S]+/.test(value) && (value.length < 6 || value.length > 18)) {
                return '密码长度为6-18位';
            }
        },
        verifyNewConPass: function (value) {
            if (!/[\S]+/.test(value)) {
                return '确认密码不能为空';
            }
            if (/[\S]+/.test(value) && (value.length < 6 || value.length > 18)) {
                return '密码长度为6-18位';
            }
            var newPass = $("#newPass").val();
            if (newPass != value) {
                return '两次密码不一致';
            }
        },
        verifyEqName: [/[\S]+/, "设备名称不能为空"],
        verifyTime: function (value) {
            var timeReg = /^(([0-1]\d)|(2[0-4])):[0-5]\d$/;
            if (/[\S]+/.test(value) && !timeReg.test(value)) {
                return '自动转仓时间格式不正确，只能输入时分(XX:XX)';
            }
        },
        verifyCompany: function (value) {
            if (value == "" || value == "-1") {
                return "请选择所属公司";
            }
        },
        verifyGroup: function (value) {
            if (value == "" || value == "-1") {
                return "请选择所属部门";
            }
        },
        verifyEquipment: function (value) {
            if (value == "" || value == "-1") {
                return "请选择设备";
            }
        },
        verifyRole: function (value) {
            if (value == "" || value == "-1") {
                return "请选择角色";
            }
        },
        verifyEnvirName: [/[\S]+/, "环境名称不能为空"],
        verifyBugMax: function (value) {
            if (!/[\S]+/.test(value)) {
                return '害虫阈值不能为空';
            }
            if (value == 0) {
                return '害虫阈值必须大于0';
            }
        },
        verifyEnvirMax: function (value) {
            if (!/[\S]+/.test(value)) {
                return '最大阈值不能为空';
            }
            var reg = /^(\-|\+)?\d+(\.\d{1,2})?$/;
            if (!reg.test(value)) {
                return '只能输入正负整数或者保留2位的小数';
            }
        },
        verifyEnvirMin: function (value) {
            if (!/[\S]+/.test(value)) {
                return '最小阈值不能为空';
            }
            var reg = /^(\-|\+)?\d+(\.\d{1,2})?$/;
            if (!reg.test(value)) {
                return '只能输入正负整数或者保留2位的小数';
            }
        },
        verifyComName: [/[\S]+/, "公司名称不能为空"],
        verifyAddress: [/[\S]+/, "地址不能为空"],
        verifyContacts: [/[\S]+/, "联系人不能为空"],
        verifyRoleName: [/[\S]+/, "角色名称不能为空"],
        verifyRoleType: function (value) {
            if (value == "" || value == "-1") {
                return "请选择角色类型";
            }
            if (value == 0) {
                return "禁止添加超级管理员";
            }
        },
        verifyAreaName: [/[\S]+/, "区域名称不能为空"],
        verifyHead: [/[\S]+/, "请选择区域负责人"],
        verifyEqType: function (value) {
            if (value == "" || value == "-1") {
                return "请选择设备类型";
            }
        },
        verifyArea: function (value) {
            if (value == "" || value == "-1") {
                return "请选择所属区域";
            }
        },
        verifyWarnTye: function (value) {
            if (value == "" || value == "-1") {
                return "请选择警报方式";
            }
        },
        verifyWarnUser: function (value) {
            if (value == "" || value == null) {
                return "请添加警报接收人";
            }
        },
        verifyDecimal1: function (value) {
            var reg = /^(\-|\+)?\d+(\.\d{1,6})?$/;
            if (/[\S]+/.test(value) && !reg.test(value)) {
                return '只能输入正负整数或者保留6位的小数';
            }
        },
        verifyDecimal2: function (value) {
            var reg = /^\d+(\.\d{1,2})?$/;
            if (/[\S]+/.test(value) && !reg.test(value)) {
                return '只能输入整数或者保留2位的小数';
            }
        },
        verifyStartTime: function (value) {
            if (!/[\S]+/.test(value)) {
                return '开始时间不能为空';
            }
            var timeReg = /^(([0-1]\d)|(2[0-4])):[0-5]\d$/;
            if (/[\S]+/.test(value) && !timeReg.test(value)) {
                return '开始时间格式不正确，只能输入时分(XX:XX)';
            }
        },
        verifyEndTime: function (value) {
            if (!/[\S]+/.test(value)) {
                return '结束时间不能为空';
            }
            var timeReg = /^(([0-1]\d)|(2[0-4])):[0-5]\d$/;
            if (/[\S]+/.test(value) && !timeReg.test(value)) {
                return '结束时间格式不正确，只能输入时分(XX:XX)';
            }
        },
        verifyCode: [/[\S]+/, "编号不能为空"],
        verifyIpAddress: function (value) {
            if (!/[\S]+/.test(value)) {
                return 'IP地址不能为空';
            }
            var reg = /^(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)$/;
            if (!reg.test(value)) {
                return 'IP地址格式不正确';
            }
        },
        verifyPort: [/[\S]+/, "端口号不能为空"],
        verifyGroupName: [/[\S]+/, "部门名称不能为空"],
        verifyVersion: [/[\S]+/, "版本号不能为空"],
        verifyUrl: [/[\S]+/, "必须上传APK文件"],
        verifyTitle: [/[\S]+/, "标题不能为空"],
        verifyContent: [/[\S]+/, "内容不能为空"],
        verifyReleaseTime: [/[\S]+/, "请选择发布日期"],
        verifyOverdueTime: [/[\S]+/, "请选择逾期日期"],
        verifyName: [/[\S]+/, "数据字典名称不能为空"],
        verifyValue: [/[\S]+/, "数据字典值不能为空"],
        verifyType: [/[\S]+/, "数据字典类型不能为空"],
        verifyCustomer: [/[\S]+/, "请选择客户"],
        verifyProductCode: function (value) {
            if (!/[\S]+/.test(value)) {
                return '产品编号不能为空';
            }
            var reg = /^([a-z]{3})(\d{11,13})$/;
            if (!reg.test(value)) {
                return '请输入完整的产品编号';
            }
        },
        verifyOperation: [/[\S]+/, "请选择操作动作"],
        verifyDeal: [/[\S]+/, "请选择处理人"],
        verifyCusName: [/[\S]+/, "客户名称不能为空"],
        verifyLevel: function (value) {
            if (value == "" || value == "-1") {
                return "请选择客户级别";
            }
        },
        verifyCharge: [/[\S]+/, "请选择负责人"],
        verifyType: function (value) {
            if (value == "" || value == "-1") {
                return "请选择类型";
            }
        },
        verifyStartTime2:[/[\S]+/, "请选择开始时间"],
        verifyNumber:[/[\S]+/, "数量不能为空"]
    });
});